<%@page import="com.railway.news.model.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
	<head>
		<%@ include file="/commons/listcssjs.jsp"%>

		<title><%=MenuColums.TABLE_ALIAS%> 维护</title>
	</head>
	<body>
		<div style="width: 1000px; padding: 0px;">
			<form id="weatherForm" name="weatherForm"
				action="${ctx}/news/Menu/saveAjax.do" method="post"
				style="display: inline;">
				
				<table class="listTable" id="safe">
                         <th   align=left colspan=2 >
							天气预报
						</th>
				<tr >
				   <td rowspan="3" width="80px" >
				       <img src="" id="weatherImg" >
				       <input  value="" id="imgUrl" name="imgUrl"   type="hidden"  />
				   </td>
				   <td >
				       
				      天气：<select id="weathername1" name="weathername" onchange="changeWeather()">
				      <option value="晴">晴</option>
				      <option value="晴转多云">晴转多云</option>
				      <option value="多云转晴">多云转晴</option>
				      <option value="晴转多云">晴转多云</option>
				      <option value="阴">阴</option>
	　　   			  <option value="多云">多云</option>
	     			  <option value="小雨">小雨</option>
	     			  <option value="中雨">中雨</option>
	      			  <option value="暴雨">中到大雨</option>
					   <option value="小雪">小雪</option>
				      <option value="中到大雪">中到大雪</option>
				      <option value="暴雪">暴雪</option>
				      <option value="雨加雪">雨加雪</option>
				      <option value="雷阵雨">雷阵雨</option>
	　　   			  <option value="浮尘">浮尘</option>
	     			  <option value="扬尘">扬尘</option>
	     			  <option value="沙尘暴">沙尘暴</option>
	      			  <option value="强沙尘暴">强沙尘暴</option>
					   <option value="大雾">大雾</option>
	               </select>
				      
					    
				   </td>
				 </tr>
				 <tr >
				   <td >
				        气温：<input id="weathername2"  name="weathername" value="" />
				   </td>
				 </tr>
				 <tr >
				   <td >
				       
				      风速：<input id="weathername3" name="weathername" value="" />
					   <input  value="" id="weatherid" name="weatherid"   type="hidden"  />
					    <input  value="weather" id="param" name="param"   type="hidden"  />
				   </td>
				 </tr>
				<tr>
				
				   <td colspan=2 >
				       <a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
						href="javascript:saveWeather()"> 保存 </a>
						 	
				   </td>
				 </tr>
				 </table>
				 <br>
				
             </form>
             <form id="safeForm" name="safeForm"
				action="${ctx}/news/Menu/saveAjax.do" method="post"
				style="display: inline;">
				
				<table class="listTable" id="safe">
                         <th colspan=2 align=left>
							安全天数
						</th>
				<tr>
				   <td  class="title" width="50px" >名称
				   </td>
				   <td  class="title" >
				      日期 
				    </td>
				 </tr>  
				<tr>
				   <td  width="50px" >
				     <input value="" id="safeName1" name="safeName1"   type="text" class="easyui-validatebox"   />
				      <input value="" id="safeId1" name="safeId1"   type="hidden"  />
				      <input  value="safe" id="param" name="param"   type="hidden"  />
				   </td>
				   <td >
				      <input value="" id="safe1" name="safe1"   type="text" class="easyui-datebox"   />
				    </td>
				 </tr> 
				 <tr>
				   <td  width="50px" >
				     <input value="" id="safeName2" name="safeName2"   type="text" class="easyui-validatebox"   />
				      <input value="" id="safeId2" name="safeId2"   type="hidden"  />
				   </td>
				   <td >
				      <input value="" id="safe2" name="safe2"   type="text" class="easyui-datebox"   />
				    </td>
				 </tr> 
				 <tr>
				   <td  width="50px" >
				     <input value="" id="safeName3" name="safeName3"   type="text" class="easyui-validatebox"   />
				      <input value="" id="safeId3" name="safeId3"   type="hidden"  />
				   </td>
				   <td >
				      <input value="" id="safe3" name="safe3"   type="text" class="easyui-datebox"   />
				    </td>
				 </tr> 
				<tr>
				   <td colspan=2 >
				       <a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
						href="javascript:saveSafe()"> 保存 </a>
					 </td>
				 </tr>
				 </table>
				 
				
             </form>
             <form id="titleForm" name="titleForm"
				action="${ctx}/news/Menu/saveAjax.do" method="post"
				style="display: inline;">
				
				<table class="listTable" id="title">
                         <th colspan=2 align=left>
							格言警句
						</th>
				 <tr>
				   <td  width="50px" >
				     <input value="" id="titlenames" name="titlenames" style="width:300"  type="text" class="easyui-validatebox"   />
				      <input value="" id="titleId" name="titleId"   type="hidden"  />
				      <input  value="title" id="param" name="param"   type="hidden"  />
				   </td> 
				 </tr> 
				 <tr>
				   <td colspan=2 >
				       <a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
						href="javascript:saveTitle()"> 保存 </a>
					 </td>
				 </tr>
				 </table>
				 
				
             </form>
				<br></br>
				<div>
					<table class="listTable" id="topTitle">

						<th colspan=4 align=left>
							顶部标题
						</th>
						<tr>
							<td colspan=4>
								<a id="btnadd" class="l-btn l-btn-plain" style="float: left;"
									href="javascript:addMenu('topTitle','')"> <span
									class="l-btn-left"><span style="padding-left: 20px;"
										class="l-btn-text icon-create">新增</span> </span> </a>
								<div class="datagrid-btn-separator"></div>
							</td>
						</tr>
						<tr>
							<td class="title">
								标题编号
							</td>
							<td class="title">
								标题名称
							</td>
							<td class="title">
								连接地址
							</td>
							<td class="title">
								操作
							</td>
						</tr>
						 
					</table>

				</div>
				<br>
				<div>
					<table class="listTable" id="menus">
						<th colspan=5 align=left>
							菜单
						</th>
						<tr>
							<td colspan=5>
								<a id="btnadd" class="l-btn l-btn-plain" style="float: left;"
									href="javascript:addMenu('menus','')"> <span
									class="l-btn-left"><span style="padding-left: 20px;"
										class="l-btn-text icon-create">新增</span> </span> </a>
								<div class="datagrid-btn-separator"></div>
							</td>
						</tr>
						<tr>
							<td class="title">
								标题编号
							</td>
							<td class="title">
								一级菜单名称
							</td>
							<td class="title">
								二级菜单名称
							</td>
							<td class="title">
								连接地址
							</td>
							<td class="title">
								操作
							</td>
						</tr>
						 
					</table>

				</div>
				<br>
				<div>
					<table class="listTable" id="leftTitle">
						<th colspan=4 align=left>
							左侧标题
						</th>
						<tr>
							<td colspan=4>
								<a id="btnadd" class="l-btn l-btn-plain" style="float: left;"
									href="javascript:addMenu('leftTitle','')"> <span
									class="l-btn-left"><span style="padding-left: 20px;"
										class="l-btn-text icon-create">新增</span> </span> </a>
								<div class="datagrid-btn-separator"></div>
							</td>
						</tr>
						<tr>
							<td class="title">
								标题编号
							</td>
							<td class="title">
								标题名称
							</td>
							<td class="title">
								连接地址
							</td>
							<td class="title">
								操作
							</td>
						</tr>
					 
					</table>

				</div>
				<br>
				<div>
					<table class="listTable" id="friendLink">
						<th colspan=6 align=left>
							友情链接一
						</th>
						<tr>
							<td colspan=6 >
								<a id="btnadd" class="l-btn l-btn-plain" style="float: left;"
									href="javascript:addMenu('friendLink','')"> <span
									class="l-btn-left"><span style="padding-left: 20px;"
										class="l-btn-text icon-create">新增</span> </span> </a>
								<div class="datagrid-btn-separator"></div>
							</td>
						</tr>
						<tr>
							<td class="title">
								标题编号
							</td>
							<td class="title">
								名称
							</td> 
							<td class="title">
								连接地址
							</td>
							<td class="title">
								操作
							</td>
						</tr>
 
					</table>

				</div>
				<div>
					<table class="listTable" id="friendLink1">
						<th colspan=6 align=left>
							友情链接二
						</th>
						<tr>
							<td colspan=6 >
								<a id="btnadd" class="l-btn l-btn-plain" style="float: left;"
									href="javascript:addMenu('friendLink1','')"> <span
									class="l-btn-left"><span style="padding-left: 20px;"
										class="l-btn-text icon-create">新增</span> </span> </a>
								<div class="datagrid-btn-separator"></div>
							</td>
						</tr>
						<tr>
							<td class="title">
								标题编号
							</td>
							<td class="title">
								名称
							</td> 
							<td class="title">
								连接地址
							</td>
							<td class="title">
								操作
							</td>
						</tr>
 
					</table>

				</div>
				
				<div>
					<table class="listTable" id="friendLink2">
						<th colspan=6 align=left>
							友情链接三
						</th>
						<tr>
							<td colspan=6 >
								<a id="btnadd" class="l-btn l-btn-plain" style="float: left;"
									href="javascript:addMenu('friendLink2','')"> <span
									class="l-btn-left"><span style="padding-left: 20px;"
										class="l-btn-text icon-create">新增</span> </span> </a>
								<div class="datagrid-btn-separator"></div>
							</td>
						</tr>
						<tr>
							<td class="title">
								标题编号
							</td>
							<td class="title">
								名称
							</td> 
							<td class="title">
								连接地址
							</td>
							<td class="title">
								操作
							</td>
						</tr>
 
					</table>

				</div>
			
			
		</div>


		<!--新增-->

		<div id="w" closed="true" class="easyui-window" title="新增"
			collapsible="false" minimizable="false" maximizable="false"
			icon="icon-save"
			style="width: 300px; height: 300px; padding: 5px; background: #fafafa;">

			<div class="easyui-layout" fit="true">

				<div region="center" border="false"
					style="padding: 10px; background: #fff; border: 1px solid #ccc;">
					<form id="forms" action="${ctx}/news/Menu/saveAjax.do"
						method="post">
						<table cellpadding="3" id="addtable">
							<tr>
								<td>
									名称：
								</td>
								<td>
									<input id="names" name="names" type="text" value=""
										class="validate-integer" />
									<input id="id" name="id" type="hidden" value=""
										class="txt01" />	
									<input id="parenId" name="parenId" type="hidden" value=""
										class="txt01" />
									<input id="locations" name="locations" type="hidden" value=""
										class="txt01" />
								</td>
							</tr>
							
							<tr>
								<td>
									连接地址：
								</td>
								<td>
									<input id="urls" name="urls" type="text"
										class="validate-integer" />
								</td>
							</tr>
							<tr>
								<td>
									编号：
								</td>
								<td>
									<input id="priors" name="priors" type="text"
										class="validate-integer" />
								</td>

							</tr>
							
						</table>
					</form>
				</div>
				<div region="south" border="false"
					style="text-align: right; height: 30px; line-height: 30px;">
					<a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
						href="javascript:saveMenu()"> 确定</a>
					<a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel"
						href="javascript:closeWindow()">取消</a>
				</div>

			</div>

		</div>

	</body>
	<script type="text/javascript"> 
	$(function(){
	 
		$('#forms').form({success:function(data){
		   
	        window.location.reload();
	        //$.messager.alert('Info', '修改成功', 'info');
	     }
	      });
	     $('#weatherForm').form({success:function(data){
		   
	        window.location.reload();
	        //$.messager.alert('Info', '修改成功', 'info');
	     }
	      });
	     $('#safeForm').form({success:function(data){
		   
	        window.location.reload();
	        //$.messager.alert('Info', '修改成功', 'info');
	       }
	     });
	      $('#titleForm').form({success:function(data){
		   
	        window.location.reload();
	        //$.messager.alert('Info', '修改成功', 'info');
	       }
	     });
	   initData();
    });
   function addrow(){
         $("#freinds").append('<tr><td>从<label><input type="text" name="fqty" width="50" /> 件');
		 $("#freinds").append('<input type="text" name="eqty" width="50" />件</label></td><td><inputtype="text" name="eqty" width="50" /></td><td><a href="javascript:void(0)" onclick="remove()">删除</a></td></tr>');
         
    } 
    function addMenu(location,parentId){
     //  $("#addtable tr:eq(1)").remove();
       $('#names').val('');
       $('#id').val('');
       $('#parenId').val(parentId);
       $('#locations').val(location);
       $('#urls').val('');
       $('#priors').val(''); 
	   $("html,body").animate({scrollTop: 0}, 0);
       $('#w').window('open');
     }
     function  update(id){
   
       $.get('${ctx}/news/Menu/showAjax.do?id='+id+'&t='+Math.random(), function(josn){
           if(josn!=""){
	           josn = josn.replace(new RegExp("null","gm"),'""');
	           var mydata = eval("("+josn+")");
	           $('#id').val(mydata.id);
		       $('#names').val(mydata.names);
		       $('#parenId').val(mydata.parenId);
		       $('#locations').val(mydata.locations);
		       $('#urls').val(mydata.urls);
		       $('#priors').val(mydata.priors); 
		       $("html,body").animate({scrollTop: 0}, 0);
		       $('#w').window('open');
	       }
       });
     }
     
     function closeWindow(){
       $('#w').window('close');
   
    
    }
    function saveMenu(){
        $('#w').window('close');
        $('#forms').submit();
    }
    function saveWeather(){ 
       
        $('#weatherForm').submit();
    } 
    function saveSafe(){ 
        
        $('#safeForm').submit();
    } 
    function saveTitle(){ 
        
        $('#titleForm').submit();
    } 
    
    function initData(){
         $.get('${ctx}/news/Menu/topList.do?t='+Math.random(), function(josn) {
               //替换空字符
             if(josn!=""){
		     josn = josn.replace(new RegExp("null","gm"),'""');
			   var mydata = eval("("+josn+")");
			   if(mydata.weather!=''){
			       var ojb=mydata.weather;
			       $("#weatherid").val(ojb.id);
			       var temp=ojb.names.split('#');
			       if(temp.length>=3){
			          $("#weathername1").val(temp[0]);
			          $("#weathername2").val(temp[1]);
			          $("#weathername3").val(temp[2]);
			       }
			      $("#weatherImg").attr('src',${ctx}ojb.urls);  
			      $("#imgUrl").val(ojb.urls);
			   }
			    if(mydata.safe1!=''){
			       var ojb=mydata.safe1; 
			       $("#safe1").val(ojb.createTimeString);
			       $("#safeId1").val(ojb.id);
			       $("#safeName1").val(ojb.names); 
			   }
			   if(mydata.safe2!=''){
			       var ojb=mydata.safe2; 
			       $("#safe2").val(ojb.createTimeString);
			       $("#safeId2").val(ojb.id);
			       $("#safeName2").val(ojb.names); 
			   }
			   if(mydata.safe3!=''){
			       var ojb=mydata.safe3; 
			       $("#safe3").val(ojb.createTimeString);
			       $("#safeId3").val(ojb.id);
			       $("#safeName3").val(ojb.names); 
			   }
			   if(mydata.title!=''){ 
			       var ojb=mydata.title;
			        
			       $("#titlenames").val(ojb.names);
			       $("#titleId").val(ojb.id);  
			       
			   }
			   if(mydata.menus!=''){
			      var ojb=mydata.menus;
			      for(var i=0;i<ojb.length;i++){
			        var content='<tr>';
			        content+='<td class="tdLabel">'+ojb[i].priors+'</td>';
					content+='<td class="tdLabel">'+ojb[i].names+'</td>';
					content+='<td class="tdLabel"></td>';
					content+='<td class="tdLabel">'+ojb[i].urls+'</td>';
					content+='<td class="tdLabel"><a href="javascript:void(0)" onclick=addMenu("menus","'+ojb[i].id+'") >添加子菜单</a>  <a href="javascript:void(0)" onclick=update("'+ojb[i].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+ojb[i].id+'") >删除</a></td>';
					
					content+='</tr>'; 
					$("#menus").append(content);
			         if(ojb[i].childrenMenu!=''){
			              
			              var children=ojb[i].childrenMenu;
			              for(var j=0;j<children.length;j++){
			                content='<tr>';
					        content+='<td >'+children[j].priors+'</td>';
					        content+='<td  ></td>';
							content+='<td >'+children[j].names+'</td>';
							content+='<td >'+children[j].urls+'</td>';
							content+='<td > <a href="javascript:void(0)" onclick=update("'+children[j].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+children[j].id+'") >删除</a></td>';
							
							content+='</tr>'; 
							$("#menus").append(content); 
							 
			            }
			         }
			      }
			   }
			   if(mydata.topTitle!=''){
			      var ojb=mydata.topTitle;
			      for(var i=0;i<ojb.length;i++){
					var content='<tr><td class="tdLabel">'+ojb[i].priors+'</td>';
					content+='<td class="tdLabel">'+ojb[i].names+'</td>';
					content+='<td class="tdLabel">'+ojb[i].urls+'</td>';
					content+='<td class="tdLabel"><a href="javascript:void(0)" onclick=update("'+ojb[i].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+ojb[i].id+'") >删除</a></td>';
					content+='</tr>'; 
					$("#topTitle").append(content); 
			         
			      }
			   }
			   if(mydata.leftTitle!=''){
			      var ojb=mydata.leftTitle;
			      for(var i=0;i<ojb.length;i++){
			        var content='<tr>';
					content+='<td class="tdLabel">'+ojb[i].priors+'</td>';
					content+='<td class="tdLabel">'+ojb[i].names+'</td>';
					content+='<td class="tdLabel">'+ojb[i].urls+'</td>';
					content+='<td class="tdLabel"><a href="javascript:void(0)" onclick=update("'+ojb[i].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+ojb[i].id+'") >删除</a></td>';
					content+='</tr>';
					$("#leftTitle").append(content);    
			         
			      }
			   }
			   if(mydata.friendLink!=''){
			       var ojb=mydata.friendLink;
			      for(var i=0;i<ojb.length;i++){ 
			        var content='<tr>';
			        content+='<td class="tdLabel">'+ojb[i].priors+'</td>';
					content+='<td class="tdLabel">'+ojb[i].names+'</td>'; 
					content+='<td class="tdLabel">'+ojb[i].urls+'</td>';
					content+='<td class="tdLabel">   <a href="javascript:void(0)" onclick=update("'+ojb[i].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+ojb[i].id+'") >删除</a></td>';
					
					content+='</tr>'; 
					 
					$("#friendLink").append(content);  
			         
			      }  //end ojb
			   }  //friendLink
			   
			    if(mydata.friendLink1!=''){
			       var ojb=mydata.friendLink1;
			      for(var i=0;i<ojb.length;i++){ 
			        var content='<tr>';
			        content+='<td class="tdLabel">'+ojb[i].priors+'</td>';
					content+='<td class="tdLabel">'+ojb[i].names+'</td>'; 
					content+='<td class="tdLabel">'+ojb[i].urls+'</td>';
					content+='<td class="tdLabel">   <a href="javascript:void(0)" onclick=update("'+ojb[i].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+ojb[i].id+'") >删除</a></td>';
					
					content+='</tr>'; 
					 
					$("#friendLink1").append(content);  
			         
			      }  //end ojb
			   }  //friendLink
			   
			    if(mydata.friendLink2!=''){
			       var ojb=mydata.friendLink2;
			      for(var i=0;i<ojb.length;i++){ 
			        var content='<tr>';
			        content+='<td class="tdLabel">'+ojb[i].priors+'</td>';
					content+='<td class="tdLabel">'+ojb[i].names+'</td>'; 
					content+='<td class="tdLabel">'+ojb[i].urls+'</td>';
					content+='<td class="tdLabel">   <a href="javascript:void(0)" onclick=update("'+ojb[i].id+'") >修改</a> <a href="javascript:void(0)" onclick=remove("'+ojb[i].id+'") >删除</a></td>';
					
					content+='</tr>'; 
					 
					$("#friendLink2").append(content);  
			         
			      }  //end ojb
			   }  //friendLink
			 }
			 
         }) ;   
         
    } 
    function remove(id){
       $.get('${ctx}/news/Menu/deleteAjax.do?id='+id, function(josn){
             window.location.reload();
       });
        
    }
    function changeWeather(){
    	 var obj=$("#weathername1").val();
    	 
    	 switch(obj)
	   　　{
	　　   case "晴":
	       $("#weatherImg").attr('src','${ctx}/images/weather/qing.jpg');
	       $("#imgUrl").val('/images/weather/qing.jpg');
	       break;
		     case "晴转多云":
	       $("#weatherImg").attr('src','${ctx}/images/weather/qingzhuanduoyun.jpg');
	       $("#imgUrl").val('/images/weather/qingzhuanduoyun.jpg');
	       break;
		    case "多云转晴":
	       $("#weatherImg").attr('src','${ctx}/images/weather/duoyunzhuanqing.png');
	       $("#imgUrl").val('/images/weather/duoyunzhuanqing.png');
	       break;
	　　   case "阴":
	       $("#weatherImg").attr('src','${ctx}/images/weather/yin.jpg');
	       $("#imgUrl").val('/images/weather/yin.jpg');
	       break;
	      case "多云":
	       $("#weatherImg").attr('src','${ctx}/images/weather/duoyun.jpg');
	       $("#imgUrl").val('/images/weather/duoyun.jpg');
	       break;
	   
	      case "小雨":
	       $("#weatherImg").attr('src','${ctx}/images/weather/xiaoyu.jpg');
	       $("#imgUrl").val('/images/weather/xiaoyu.jpg');
	       break;
	      case "中雨":
	       $("#weatherImg").attr('src','${ctx}/images/weather/zhongyu.jpg');
	       $("#imgUrl").val('/images/weather/zhongyu.jpg');
	       break;
	      case "暴雨":
	       $("#weatherImg").attr('src','${ctx}/images/weather/baoyu.jpg');
	       $("#imgUrl").val('/images/weather/baoyu.jpg');
	       break;
	      case "小雪":
	       $("#weatherImg").attr('src','${ctx}/images/weather/xiaoxue.jpg');
	       $("#imgUrl").val('/images/weather/xiaoxue.jpg');
	       break;
	       case "中到大雪":
	       $("#weatherImg").attr('src','${ctx}/images/weather/xue.jpg');
	       $("#imgUrl").val('/images/weather/xue.jpg');
	       break;
		    case "暴雪":
	       $("#weatherImg").attr('src','${ctx}/images/weather/baoxue.gif');
	       $("#imgUrl").val('/images/weather/baoxue.gif');
	       break;
		      case "雨加雪":
	       $("#weatherImg").attr('src','${ctx}/images/weather/yujiaxue.gif');
	       $("#imgUrl").val('/images/weather/yujiaxue.gif');
	       break;
		         case "雷阵雨":
	       $("#weatherImg").attr('src','${ctx}/images/weather/leizhenyu.gif');
	       $("#imgUrl").val('/images/weather/leizhenyu.gif');
	       break;
		           case "浮尘":
	       $("#weatherImg").attr('src','${ctx}/images/weather/fushen.gif');
	       $("#imgUrl").val('/images/weather/fushen.gif');
	       break;
		              case "扬尘":
	       $("#weatherImg").attr('src','${ctx}/images/weather/yangshen.gif');
	       $("#imgUrl").val('/images/weather/yangshen.gif');
	       break;
		                case "沙尘暴":
	       $("#weatherImg").attr('src','${ctx}/images/weather/shashenbao.gif');
	       $("#imgUrl").val('/images/weather/shashenbao.gif');
	       break;
		             case "强沙尘暴":
	       $("#weatherImg").attr('src','${ctx}/images/weather/qiangshashenbao.gif');
	       $("#imgUrl").val('/images/weather/qiangshashenbao.gif');
	       break;
		   	             case "大雾":
	       $("#weatherImg").attr('src','${ctx}/images/weather/wu.gif');
	       $("#imgUrl").val('/images/weather/wu.gif');
	       break;

	　　   default:
	　　     $("#weatherImg").attr('src','${ctx}/images/weather/qing.jpg');
	　　   }
    	  
    	 
    }
    
 </script>
</html>


